<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateTemplateTodoTable extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('template_todo', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);

        //添加数据字段
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '自增ID'])
            ->addColumn('name', 'string', ['default' => '', 'limit' => 128, 'comment' => '模板名称'])
            ->addColumn('type', 'enum', ['values' => 'standard_meeting,standard_review,default', 'default' => 'default', 'comment' => '模板类型:standard_meeting 标准会议待办,standard_review 标准审核'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->addColumn('step_category_id', 'string', ['default' => '', 'limit' => 128, 'comment' => '关联环节id'])
            ->addColumn('start_man', 'json', ['null' => true, 'comment' => '发起人'])
            ->addColumn('participant_man', 'json', ['null' => true, 'comment' => '参与人'])
            ->addColumn('job_option', 'json', ['null' => true, 'comment' => '工作事项'])
            ->addColumn('after_option', 'json', ['null' => true, 'comment' => '后续事项'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('updated_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('updated', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间']);

        //执行创建
        $table->create();
    }
}
